<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link href="${root!}/static/css/layout.css" rel="stylesheet" type="text/css" />
<link href="${root!}/static/css/skin.css" rel="stylesheet" type="text/css" />
<link href="${root!}/static/css/dialog.css" rel="stylesheet" type="text/css" />
<link href="${root!}/static/css/tab.css" rel="stylesheet" type="text/css" />

<script src="${root!}/static/Js/jquery-1.4.2.js" type="text/javascript"></script>

<script src="${root!}/static/js/layout.js" type="text/javascript"></script>

<script src="${root!}/static/js/dialog.js" type="text/javascript"></script>

<script src="${root!}/static/js/tab.js" type="text/javascript"></script>

<script src="${root!}/static/js/row.js" type="text/javascript"></script>

<script src="${root!}/static/js/form.js" type="text/javascript"></script>

<script>
	var RootPath = "${root!}";
	var FormCodeUrl = RootPath + "/form/formControl";
	var FormSubmitMethod = "save";
	var FormSubmitAction = "${action!}";
	
	$(function() {
		HideTab("tab5");
        
        //控件初始化
        $("#lstHeightNumber").val("${bean.heightNumber!}");
        $("#lstFormControlType").val("${bean.formControlType!}");
        var widthType="${bean.widthType!}";
        if(widthType=="1")
        {
        	$("#rdoWidthType1").attr("checked","true");
        }
        else if(widthType=="2")
        {
        	$("#rdoWidthType2").attr("checked","true");
        }
        
        var formControlType = $("#lstFormControlType").val();
        if (formControlType.length > 0) {
            ProcessTab();
        }
        
        $("#lstFormControlType").change(function(){
        	if(this.value.length>0)
        	{
        		ProcessTab();
        	}
        	else
        	{
        		HideTab("tab5");
        	}
        });
        
	});
	
	function ProcessTab(pageCode) {
		ShowTab("tab5");
    }
	
	function SubmitClick() {
		if (!CheckForm()) {
			return false;
		} else {
			SubmitForm();
		}
	}

	function SelectForm()
	{
		var currentId;
		var formId = document.getElementById("hidFormId").value;
		var formTabId = document.getElementById("hidFormTabId").value;
		if(formTabId.length>0)
		{
			currentId=formTabId;
		}
		else
		{
			currentId=formId;
		}
        
        var dataMapper = "form.form.selectTree";
        var searchObject={};
        searchObject.pageClassifyCode="bdy";
        var searchMapper = JSON.stringify(searchObject);
        searchMapper = searchMapper.replace(/\%/g, "%25");
        searchMapper = searchMapper.replace(/\+/g, "%2B");
        searchMapper = searchMapper.replace(/\&/g, "%26");
        searchMapper = encodeURIComponent(searchMapper);
        CommonDialog("/components/tree/treeDialog?selectType=1&expandType=1&currentId="+currentId+"&dataMapper="+dataMapper+"&searchMapper="+searchMapper, "选择表单", 600, 400, function(v) {

            var returnObj = eval("(" + unescape(v) + ")");
            if (returnObj) {

            	var nodeId=returnObj.NodeId;
            	var nodeText=returnObj.NodeText;
            	var parentNodeId=returnObj.ParentNodeId;
            	var parentNodeText=returnObj.ParentNodeText;
            	
            	if(parentNodeText.length>0)
            	{
            		$("#hidFormTabId").val(nodeId);
            		$("#hidFormId").val(parentNodeId);
            		$("#txtFormName").val(parentNodeText+"."+nodeText);
            	}
            	else
            	{
             		$("#hidFormTabId").val("");
            		$("#hidFormId").val(nodeId);
            		$("#txtFormName").val(nodeText);
            	}
            	
            	var formId=$("#hidFormId").val();
            	var parentTableId=getTableByFormId(formId);
            	$("#hidParentTableId").val(parentTableId);
            	
            }

        });
	}
	
	function getTableByFormId(formId)
	{
		var ret="";
		
		$.ajax({
			type : "GET",
			async: false,
			url : FormCodeUrl + "/getTableByFormId?formId=" + formId,
			success : function(msg) {
				ret=msg;
			}
		});
		
		return ret;
	}
	
	function SelectSaveField()
	{
		var currentId = document.getElementById("hidSaveFieldId").value;
	
		var dataMapper = "frame.field.selectTree";
        var searchObject={};
        searchObject.tableId=$("#hidParentTableId").val();
        searchObject.multiValueKey="tableId";
        var searchMapper = JSON.stringify(searchObject);
        searchMapper = searchMapper.replace(/\%/g, "%25");
        searchMapper = searchMapper.replace(/\+/g, "%2B");
        searchMapper = searchMapper.replace(/\&/g, "%26");
        searchMapper = encodeURIComponent(searchMapper);
        
        CommonDialog("/components/tree/treeDialog?selectType=2&expandType=1&onlyLeafSelect=true&currentId="+currentId+"&dataMapper="+dataMapper+"&searchMapper="+searchMapper, "选择字段", 600, 400, function(v) {

            
        	var ids="";
        	var texts="";
        	var parentIds="";
        	var parentTexts="";
        	if(v.length>0)
        	{
        		var selectArray = v.split(",");
        		for (var i = 0; i < selectArray.length; i++) {
        			var selectItem = selectArray[i];
        			
        			var returnObj = eval("(" + unescape(selectItem) + ")");
        			if (returnObj) {
       				 	ids += ",";
                        ids += returnObj.NodeId;
                        texts += ",";
                        texts += (returnObj.ParentNodeText+"."+returnObj.NodeText);
                        parentIds += ",";
                        parentIds += returnObj.ParentNodeId;
                        parentTexts += ",";
                        parentTexts += returnObj.ParentNodeText;
       			 	}
        	
        		}
        		if (ids.length > 0) {
                    ids = ids.substring(1);
                    texts = texts.substring(1);
                    parentIds = parentIds.substring(1);
                    parentTexts = parentTexts.substring(1);
                }
        	}
        	
        	$("#hidSaveFieldId").val(ids);
        	$("#txtSaveFieldName").val(texts);
        	$("#hidSaveTableId").val(parentIds);
        	$("#hidSaveTableName").val(parentTexts);
        	

        });
	}
	
</script>

</head>
<body>
	<form id="myform">
		<div class="container">
			<div class="fullwidth">
				<div class="buttonGroup h30">
					<input type="button" value="确定" id="btnSubmit"
						onclick="SubmitClick();" /> <input type="button" value="取消"
						id="btnInsert" onclick="CloseWindow();" />
				</div>
			</div>
			<div class="hiddencalc fullwidth h4"></div>

	        <div class="tabGroup fullwidth">
	            <div class="tab fullheight selected" id="tab1" target="page1">
	                <span class="tableft"></span><font>基本信息</font><span class="tabright"><span class="hiddencalc inputresult init"></span></span>
	            </div>
	            <div class="tab fullheight" id="tab5" target="page5">
	                <span class="tableft"></span><font>扩展信息</font><span class="tabright"><span class="hiddencalc inputresult init"></span></span>
	            </div>
	        </div>

			<div class="hiddencalc fullwidth h4"></div>
			<div class="fullwidth calcheight onlyscrolly" id="page1">
				<div class="formcontainer calcwidth">
					<div class="formitem halfwidth h30">
						<div class="label w150">
							<font class="labeltext">控件编号：</font>
						</div>
						<div class="control calcwidth">
							<input type="text" class="calcwidth" id="txtFormControlId"
								name="txtFormControlId" value="${bean.formControlId!}" readonly />
						</div>
					</div>
					<div class="formitem halfwidth h30">
						<div class="label w150">
							<font class="labeltext">控件名称：</font>
						</div>
						<div class="control calcwidth">
							<input type="text" class="calcwidth" id="txtFormControlTitle"
								name="txtFormControlTitle" value="${bean.formControlTitle!}" /><span
								class="hiddencalc inputresult init" minlength="1" maxlength="50"
								controlname="控件名称" bindcontrol="txtFormControlTitle"></span>
						</div>
					</div>
					<div class="formitem halfwidth h30">
						<div class="label w150">
							<font class="labeltext">控件容器：</font>
						</div>
						<div class="control calcwidth">
							<input type="text" class="calcwidth" id="txtFormName"
								name="txtFormName" value="${formName!}" readonly />
							<font><a href="javascript:void(0);" onclick="SelectForm()">【选择】</a></font>
							<input type="hidden" id="hidFormId" name="hidFormId" value="${bean.formId!}" />
							<input type="hidden" id="hidFormTabId" name="hidFormTabId" value="${bean.formTabId!}" />
							<span class="hiddencalc inputresult init" minlength="1"
								controlname="保存表" bindcontrol="txtFormName"></span>
						</div>
					</div>
					<div class="formitem halfwidth h30">
						<div class="label w150">
							<font class="labeltext">控件分组：</font>
						</div>
						<div class="control calcwidth">
							<input type="text" class="calcwidth" id="txtGroupId"
								name="txtGroupId" value="${bean.groupId!}" />
						</div>
					</div>
					<div class="formitem halfwidth h30">
						<div class="label w150">
							<font class="labeltext">宽度类型：</font>
						</div>
						<div class="control calcwidth">
							<input type="radio" id="rdoWidthType1" name="rdoWidthType" value="1"  />
							<font>半行</font>
							<input type="radio" id="rdoWidthType2" name="rdoWidthType" value="2" />
							<font>整行</font>
						</div>
					</div>
					<div class="formitem halfwidth h30">
						<div class="label w150">
							<font class="labeltext">高度：</font>
						</div>
						<div class="control calcwidth">
							<select class="calcwidth" id="lstHeightNumber" name="lstHeightNumber">
								<option value="">请选择</option>
								<option value="30">30</option>
								<option value="150">150</option>
							</select>
						</div>
					</div>
					<div class="formitem halfwidth h30">
						<div class="label w150">
							<font class="labeltext">控件类型：</font>
						</div>
						<div class="control calcwidth">
							<select class="calcwidth" id="lstFormControlType" name="lstFormControlType">
								<option value="">请选择</option>
								<option value="11">文本框</option>
								<option value="12">日期框</option>
								<option value="13">列表框</option>
								<option value="14">隐藏域</option>
								<option value="15">多行文本</option>
								<option value="16">单选框</option>
								<option value="17">多选框</option>
								<option value="18">上传文件</option>
								<option value="19">选择分类</option>
								<option value="20">标签</option>
							</select>
						</div>
					</div>
					<div class="formitem halfwidth h30">
						<div class="label w150">
							<font class="labeltext">顺序号：</font>
						</div>
						<div class="control calcwidth">
							<input type="text" class="calcwidth" id="txtOrderNumber"
								name="txtOrderNumber" value="${bean.orderNumber!}" /><span
								class="hiddencalc inputresult init" validateregular="数字"
								minlength="1" maxlength="50" controlname="顺序号"
								bindcontrol="txtOrderNumber"></span>
						</div>
					</div>
					<div class="formitem fullwidth h30">
						<div class="label w150">
							<font class="labeltext">相关字段：</font>
						</div>
						<div class="control calcwidth">
							<input type="text" class="calcwidth" id="txtSaveFieldName"
								name="txtSaveFieldName" value="${saveFieldName!}" readonly />
							<font><a href="javascript:void(0);" onclick="SelectSaveField()">【选择】</a></font>
							<input type="hidden" id="hidSaveFieldId" name="hidSaveFieldId" value="${saveFieldId!}" />
							<input type="hidden" id="hidSaveTableId" name="hidSaveTableId" value="${saveTableId!}" />
							<input type="hidden" id="hidSaveTableName" name="hidSaveTableName" value="${saveTableName!}" />
							<input type="hidden" id="hidParentTableId" name="hidParentTableId" value="${parentTableId!}" />
							<span class="hiddencalc inputresult init" minlength="0"
								controlname="相关字段" bindcontrol="txtSaveFieldName"></span>
						</div>
					</div>


				</div>
				<div class="scrollwidth hiddencalc" style="display: none;">
					<!--滚动条占位宽度-->
				</div>
			</div>
			
			<div class="fullwidth calcheight onlyscrolly" id="page5">
				<input type="hidden" id="hidFormParamIds" name="hidFormParamIds" value="${formParamIds!}" />
				<table border="1" width="100%" id="ParamRow1" class="showDataTable" cellspacing="0">
					<#if listFormParams??><#list listFormParams as m>
					<tr class="showDataRow" id="row_${m.ParamsId!}">
						<td width="80">${m.ParamsCode!}：</td>
						<td width="400">
							${m.Control!}
						</td>
						<td>
							${m.ParamsText!}
							${m.Script!}
							<input type="hidden" id="hidParamsId" name="hidParamsId" />
						</td>
					</tr>
					</#list></#if>
				</table>
			</div>
		</div>
	</form>
</body>
</html>
